Blueprint Help Send comments on this topic.
System Calls

Glossary Item Box

This section seems a bit pointless really.  Might be better moved elsewhere

 

CLIP provides a number of calls that interact with the CLIP Process. (See the Reference Section Runtime System Calls for a detailed description of each).

Examples

// Exiting

if ( ClpAmAutonomous() )
{
   ClpDiag( "Exit called - Shut down everything" );
   ClpExit( 0 );
}
else if ( ClpAmRootMaster() )
{
   ClpDiag( "Exit called by Master - Shut down everything" );
   ClpSleep( 5000 );
   ClpExit( 0 );
}
else
{
   ClpDiag( "Exit called by Slave %d - Shut down slave", ClpThisSlaveId() );
   ClpRetireThisProcess();
}

 

// Heartbeat

while ( TRUE )
{
   Uns memUsage = ClpMemAllocated();

   Uns concurrency = ClpConcurrency();
   Uns peakConcurrency = ClpMaxConcurrent();

   ClpDiag( "Concurrency = Current %d  Peak       %d",
            concurrency, peakConcurrency );
   ClpDiag( "Memory MB   = Current %d  Available  %d",
            MB(memUsage), MB(MAX_MEM) );

   ClpSleep( 1000 );
}

 

// Job creation

Uns maxNumSlaves = clp_max_num_slaves();
Uns lastNumSlaveCPUs = 0;

Uns numTasks = 0;
Uns taskSize = JOB_SIZE;

while ( TRUE )
{
   // count num of available CPUs 
   Uns numSlaveCPUs = 0;

   for ( Uns i = 0; i < maxNumSlaves; ++i )
   {
      if ( SlaveConnected( i ) )
         numSlaveCPUs += ClpSlaveSmpIdx();
   }

   // has num slave CPUs changed
   if ( numSlaveCPUs != lastNumSlaveCPUs )
   {
      // calculate number of tasks
      lastNumSlaveCPUs = numSlaveCPUs;
      numTasks = lastNumSlaveCPUs + 1;
      numTasks *= numTasks;

      // calculate task size (rounded up)
      taskSize = 1 + (JOB_SIZE-1) / numTasks;
   }

   // Do all tasks
   Uns taskStart = 0;

   for ( Uns t = 0; t < numTasks; ++t )
   {
      // do each full task
      if ( taskStart + taskSize < JOB_SIZE )
         Do( t, taskStart, taskSize );

      else // do underflow bit
         Do( t, taskStart, JOB_SIZE - taskStart );

      taskStart += taskSize;
   }
}